﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using NFine.Application.Biz;
using NFine.Code;

namespace NFine.Web.Areas.MemberManage.Controllers
{
    public class IntegralDetailController : Controller
    {
        //
        // GET: /MemberManage/IntegralDetail/
        IntegralDetailApp integralDetailApp = new IntegralDetailApp();

        public ActionResult Index()
        {
            return View();
        }

        [HttpGet]
        [HandlerAjaxOnly]
        [HandlerLogin]
        public ActionResult GetListForBonus(Pagination pagination, int IntegralType, string TimeStart, string TimeEnd)
        {
            //TODO 通过session获取会员id，如果为空则默认是管理员登录获取所有记录
            //string memberId = ""
            var u = OperatorProvider.Provider.GetCurrent();
            string memberId = "";
            if (u != null && !u.IsSystem&&!u.IsSys)
            {
                memberId = u.UserId;
            }
            ///2018 4 30 修改了视图，用于修改积分转赠时，赠出和收到的两条记录重复
            var data = new
            {
                rows =
                integralDetailApp.GetListForIntegral(pagination, memberId, IntegralType, TimeStart, TimeEnd),
                total = pagination.total,
                page = pagination.page,
                records = pagination.records
            };
            return Content(data.ToJson());
        }

    }
}
